package com.cn.wanxi.service.impl;

import com.cn.wanxi.dao.ProductDao;
import com.cn.wanxi.dao.impl.ProductImpl;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.ProductService;

public class ProductServiceImpl implements ProductService {
    private ProductDao productDao = new ProductImpl();

    @Override
    public ResultModel findAll(ProductModel model) {
//        ResultModel resultModel=new ResultModel();
//        ProductDao productDao = new ProductImpl();
//        resultModel.setCode(0);
//        resultModel.setData(productDao.findAll(model));
//        resultModel.setCount(productDao.getCount(model));
//        return resultModel;
        return ResultModel.getInstance(productDao.getCount(model), productDao.findAll(model));
    }

    @Override
    public ResultModel add(ProductModel model) {
//        return null;
        return ResultModel.getInstance(productDao.add(model));
    }

    @Override
    public ResultModel getCount(ProductModel productModel) {
        return ResultModel.getInstance(productDao.getCount(productModel));
    }

    @Override
    public ResultModel findById(ProductModel productModel) {
        return ResultModel.getInstance(productDao.findById(productModel));
    }

    @Override
    public ResultModel update(ProductModel model) {
        return ResultModel.getInstance(productDao.update(model));
    }

    @Override
    public ResultModel del(ProductModel productModel) {
        return ResultModel.getInstance(productDao.del(productModel));
    }

    @Override
    public ResultModel enable(ProductModel productModel) {
        return ResultModel.getInstance(productDao.enable(productModel));
    }
}
